home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / m / hypot.man < prev    next >
Encoding:
Text File  |  1989-09-06  |  2.0 KB  |  67 lines

  1.  
  2.  
  3.  
  4. HYPOT            Mathematical Library Procedures            HYPOT
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      hypot, cabs - Euclidean distance, complex absolute value
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<mmaatthh..hh>>
  13.  
  14.      ddoouubbllee hhyyppoott((xx,,yy))
  15.      ddoouubbllee xx,,yy;;
  16.  
  17.      ddoouubbllee ccaabbss((zz))
  18.      ssttrruucctt {{ddoouubbllee xx,,yy;;}} zz;;
  19.  
  20. DDEESSCCRRIIPPTTIIOONN
  21.      Hypot(x,y) and cabs(x,y) return sqrt(x*x+y*y) computed in
  22.      such a way that underflow will not happen, and overflow
  23.      occurs only if the final result deserves it.
  24.  
  25.      hypot(infinity,v) = hypot(v,infinity) = +infinity for all v,
  26.      including _N_a_N.
  27.  
  28. EERRRROORR ((dduuee ttoo RRoouunnddooffff,, eettcc..))
  29.      Below 0.97 _u_l_ps.  Consequently hypot(5.0,12.0) = 13.0
  30.      exactly; in general, hypot and cabs return an integer when-
  31.      ever an integer might be expected.
  32.  
  33.      The same cannot be said for the shorter and faster version
  34.      of hypot and cabs that is provided in the comments in
  35.      cabs.c; its error can exceed 1.2 _u_l_ps.
  36.  
  37. NNOOTTEESS
  38.      As might be expected, hypot(v,_N_a_N) and hypot(_N_a_N,v) are _N_a_N
  39.      for all _f_i_n_i_t_e v; with "reserved operand" in place of "_N_a_N",
  40.      the same is true on a VAX.  But programmers on machines
  41.      other than a VAX (it has no infinity) might be surprised at
  42.      first to discover that hypot(+_infinity,_N_a_N) = +infinity.
  43.      This is intentional; it happens because hypot(infinity,v) =
  44.      +infinity for _a_l_l v, finite or infinite.  Hence
  45.      hypot(infinity,v) is independent of v.  Unlike the reserved
  46.      operand on a VAX, the IEEE _N_a_N is designed to disappear when
  47.      it turns out to be irrelevant, as it does in
  48.      hypot(infinity,_N_a_N).
  49.  
  50. SSEEEE AALLSSOO
  51.      math(3M), sqrt(3M)
  52.  
  53. AAUUTTHHOORR
  54.      W. Kahan
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 12, 1986                          1
  64.  
  65.  
  66.  
  67.